package com.forestar.mapControl.mapview.multitouch;

import android.graphics.drawable.BitmapDrawable;

import com.forestar.mapControl.mappool.MzTileBean;
import com.forestar.mapControl.mapview.CacheCanvas;
import com.forestar.mapControl.utils.LogD;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

/**
 * created by  xzk
 * 2020/8/16   15:25
 * 说明:  图层信息，表示，此时屏幕需要多少层图层信息
 */
public class LayerInfo {

    //需要持有，屏幕显示的影像key
    private HashMap<String,MzTileBean> layerForTile = new HashMap<>(30);

    //图层的影像来源 sourceKey
    private String sourceKey;
    private CacheCanvas canvasLayer;

    private int index;

    public HashMap<String, MzTileBean> getLayerForTile() {
        return layerForTile;
    }

    public CacheCanvas getCanvasLayer() {
        return canvasLayer;
    }
    private int completeNum = 0;

    public boolean drawComplete(){
        completeNum++;
        LogD.d("总共使用次数:"+completeNum);
        Iterator<String> iterator = layerForTile.keySet().iterator();
        boolean complete = true;
        while (iterator.hasNext()){
            String key = iterator.next();
            if(layerForTile.get(key).getState() < MzTileBean.LOAD_STATE_COMPLETE){
                complete = false;
                break;
            }
        }
        if(completeNum%10 ==1){
            complete = true;
        }
        return complete;
    }

    public void setCanvasLayer(CacheCanvas canvasLayer) {
        this.canvasLayer = canvasLayer;
    }

    public void setLayerForTile(HashMap<String, MzTileBean> layerForTile) {
        this.layerForTile = layerForTile;
    }

    public String getSourceKey() {
        return sourceKey;
    }

    public void setSourceKey(String sourceKey) {
        this.sourceKey = sourceKey;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
